$(function() {
    attachHomeLogin();
});






function removeHomeLogin() {
    
}







function attachHomeLogin() {
    
    
    
    
    
    
    $('.oauthpopup').click(function() {
        $.oauthpopup({
            path: $(this).attr('href'),
            windowName: 'oauthpopup',
            windowOptions: 'location=0,status=0,width=550,height=420,fullscreen=0,resizable=0',
            callback: function(){
                window.location.reload();
            }
        });
        
        return false;
    })
    
    
    
    
    
    
    $('#connection').change(function() {
        
        var objData = {
            connection: $(this).val(),
            csrf_test_name: $.cookie(_csrf)
        };
        
        $.ajax({
            type: "POST",
            url: site_url('/ajax/general/decode-connection/'),
            data: objData,
            dataType: 'json',
            beforeSend: function() {
                //show_loading();
            },
            success: function(json) {
                
                if(json.error === false) {
                    $('#type').val(json.connection.type);
                    $('#name').val(json.connection.name);
                    $('#host').val(json.connection.host);
                    $('#username').val(json.connection.username);
                    $('#password').val(json.connection.password);
                    $('#port').val(json.connection.port);
                }
                
                //hide_loading();
            }
        });
        
    });
    
    
    
    
}